<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="joda" uri="http://www.joda.org/joda/time/tags"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>国安</title>
<meta name="viewport"
	content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no;">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<link href="${ctx}/static/weixin/hotels.css" rel="stylesheet"
	type="text/css">
<script src="${ctx}/static/weixin/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="${ctx}/static/weixin/main.js"></script>
</head>

<body id="wrap" style="">
	<style>
.deploy_ctype_tip {
	z-index: 1001;
	width: 100%;
	text-align: center;
	position: fixed;
	top: 50%;
	margin-top: -23px;
	left: 0;
}

.deploy_ctype_tip p {
	display: inline-block;
	padding: 13px 24px;
	border: solid #d6d482 1px;
	background: #f5f4c5;
	font-size: 16px;
	color: #8f772f;
	line-height: 18px;
	border-radius: 3px;
}
</style>
	<div class="cardexplain">
		<jsp:include page="${ctx}/weixin/coach/coachConfig" />

		<!--intro-->

		<form method="post" action="${ctx}/weixin/coach/update" id="form">
			<input type="hidden" name="id" value="${coach.id}" /> <input
				type="hidden" name="type" value="${coach.type}" />

			<ul class="round">
				<li class="title mb"><span class="none">请填预约信息</span></li>
				<c:if test="${coach.type == 2}">
					<li class="nob">
						<table width="100%" border="0" cellspacing="0" cellpadding="0"
							class="kuang">
							<tbody>
								<tr>
									<th style="height: 41px">练车间隔时间(分钟)</th>
									<td><select class="px" name="jg" id="jg">
											<option value="">请选择</option>
											<option value="15"
												${coach.jg == '15'? 'selected="selected"':''}>15</option>
											<option value="20"
												${coach.jg == '20'? 'selected="selected"':''}>20</option>
											<option value="30"
												${coach.jg == '30'? 'selected="selected"':''}>30</option>
											<option value="60"
												${coach.jg == '60'? 'selected="selected"':''}>60</option>
									</select>
								</tr>
							</tbody>
						</table>
					</li>
				</c:if>
				<c:if test="${coach.type == 3}">
					<input type="hidden" name="jg" id="jg" value="NUN" />
				</c:if>
				<c:if test="${coach.type == 2}">
					<li class="nob">
						<table width="100%" border="0" cellspacing="0" cellpadding="0"
							class="kuang">
							<tbody>
								<tr>
									<th style="height: 41px">练车时间</th>
									<td><select class="px" name="openHours" id="openHours"
										multiple="multiple">
											<c:forEach var="ohs" items="${ohs}" varStatus="status">
												<option value="${ohs}"
													<c:forEach var="oh" items="${openhours}" varStatus="status"><c:if test="${ohs == oh}">selected="selected"</c:if></c:forEach>>${ohs}</option>
											</c:forEach>
									</select></td>
								</tr>
							</tbody>
						</table>
					</li>
				</c:if>
				<c:if test="${coach.type == 3}">
					<li class="nob">
						<table width="100%" border="0" cellspacing="0" cellpadding="0"
							class="kuang">
							<tbody>
								<tr>
									<th rowspan=3 style="height: 120px">练车时间</th>
									<td>上午:</td>
									<td><select class="px" name="threeCoachConfig" id="amNo" >
											<option
												<c:if test="${threeCoachNos[0] == '0'}">selected="selected"</c:if> value="0">0</option>
											<option
												<c:if test="${threeCoachNos[0] == '1'}">selected="selected"</c:if> value="1">1</option>
											<option
												<c:if test="${threeCoachNos[0] == '2'}">selected="selected"</c:if> value="2">2</option>
									</select></td>
									<td>人</td>
								</tr>
								<tr>
									<td>下午:</td>
									<td><select class="px" name="threeCoachConfig" id="pmNo">
											<option
												<c:if test="${threeCoachNos[1] == '0'}">selected="selected"</c:if> value="0">0</option>
											<option
												<c:if test="${threeCoachNos[1] == '1'}">selected="selected"</c:if> value="1">1</option>
											<option
												<c:if test="${threeCoachNos[1] == '2'}">selected="selected"</c:if> value="2">2</option>
									</select></td>
									<td>人</td>
								</tr>
								<tr>
									<td>晚上:</td>
									<td><select class="px" name="threeCoachConfig" id="atNo">
											<option
												<c:if test="${threeCoachNos[2] == '0'}">selected="selected"</c:if> value="0">0</option>
											<option
												<c:if test="${threeCoachNos[2] == '1'}">selected="selected"</c:if> value="1">1</option>
											<option
												<c:if test="${threeCoachNos[2] == '2'}">selected="selected"</c:if> value="2">2</option>
									</select></td>
									<td> 人</td>
								</tr>
							</tbody>
						</table>
					</li>
				</c:if>
				<li class="nob">
					<table width="100%" border="0" cellspacing="0" cellpadding="0"
						class="kuang">
						<tbody>
							<tr>
								<th style="height: 41px">练车日期</th>
								<td><joda:format value="${coach.coachTime}"
										pattern="yyyy-MM-dd" /></td>
							</tr>
						</tbody>
					</table>
				</li>
				<li class="nob">
					<table width="100%" border="0" cellspacing="0" cellpadding="0"
						class="kuang">
						<tbody>
							<tr>
								<th style="height: 41px">状态</th>
								<td>${coach.status == 1?'开启中':'已取消'}</td>
							</tr>
						</tbody>
					</table>
				</li>
			</ul>
			<div class="footReturn" style="text-align: center">
				<input type="button" style="margin: 0 auto 20px auto; width: 90%"
					class="submit" value="保存并开启" onclick="tgSubmit()"> <input
					type="reset" style="margin: 0 auto 20px auto; width: 90%"
					class="submit" value="重置"> <input type="button"
					style="margin: 0 auto 20px auto; width: 90%" class="submit"
					value="返回" onclick="history.go(-1);">
			</div>
		</form>


		<script>
			function showTip(tipTxt) {
				var div = document.createElement('div');
				div.innerHTML = '<div class="deploy_ctype_tip"><p>' + tipTxt
						+ '</p></div>';
				var tipNode = div.firstChild;
				$("#wrap").after(tipNode);
				setTimeout(function() {
					$(tipNode).remove();
				}, 1500);
			}
			function tgSubmit() {
				//
				var name = $("#jg").val();
				if ($.trim(name) == "") {
					showTip('请输入练车间隔时间(分钟)');
					return false;
				}
				<c:if test="${coach.type == 2}">
				var tel = $("#openHours").val();
				if ($.trim(tel) == "") {
					showTip('请输入练车时间');
					return false;
				}
				</c:if>
				<c:if test="${coach.type == 3}">
				var pmNo = $("#pmNo").val();
				var amNo = $("#amNo").val();
				var atNo = $("#atNo").val();

				if ($.trim(pmNo) == "0" && $.trim(amNo) == "0" && $.trim(atNo) == "0") {
					showTip('请设置练车时间');
					return false;
				}
				</c:if>
				$('#form').get(0).submit();
			}

			$('#jg').change(function() {
				formtOpenHours($(this).val());
			});
			<c:if test="${coach.type == 2}">
			function formtOpenHours(jg) {
				$('#openHours').empty();
				jg = parseInt(jg);
				if (jg == 15 || jg == 20 || jg == 30 || jg == 60) {
					for (var i = 0; i < 23; i++) {
						if (i != 12) {
							$('#openHours').append(
									"<option value='"+ i +":00'>" + i
											+ ":00</option>");
							var isMAX = 60;
							var start = 0;
							while (true) {
								start = start + jg;
								var f = start;
								if (start == isMAX) {
									break;
								}
								$('#openHours').append(
										"<option value='"+ i +":"+f+"'>" + i
												+ ":" + f + "</option>");

							}
						}
					}
				}
			}
			</c:if>
		</script>
	</div>

</body>
</html>